RAIS  3.2
C:/Projekte/RAIS/common/MessageBoxRestriction.cs
Go to the documentation of this file.
00001 
00028 using System;
00029 using System.Collections.Generic;
00030 using System.Text;
00031 using System.Data;
00032 
00033 namespace RAIS.Common.UserManagement
00034 {
00038     public class MessageBoxRestriction : DBObject
00039     {
00040         #region Fields
00041         Region region;                             
00042         District district;             
00043         Facility facility;             
00044         Practice practice;             
00045         DateTime validFrom;
00046         DateTime validUntil;
00047         bool isDeleted;
00048         string logOperation;
00049         DateTime logOperationDate;
00050         #endregion
00051         #region Properties
00052 
00055         public string LogOperation
00056         {
00057             get
00058             {
00059                 return this.logOperation;
00060             }
00061         }
00062 
00066         public DateTime LogOperationDate
00067         {
00068             get { return this.logOperationDate; }
00069         }
00070 
00074         public bool IsDeleted 
00075         {
00076             get 
00077             {
00078                 if (this.isDeleted != null)
00079                     return this.isDeleted;
00080                 return false;
00081             }
00082         }
00083 
00087         public string Deleted
00088         {
00089             get
00090             {
00091                 if (this.isDeleted)
00092                     return "Yes";
00093                 return "No";
00094             }
00095         }
00096 
00100         public Region Region
00101         {
00102             get { return this.region; }
00103             set { this.region = value; }
00104         }
00108         public District District
00109         {
00110             get { return this.district; }
00111             set { this.district = value; }
00112         }
00116         public Facility Facility
00117         {
00118             get { return this.facility; }
00119             set { this.facility = value; }
00120         }
00124         public Practice Practice
00125         {
00126             get { return this.practice; }
00127             set { this.practice = value; }
00128         }
00132         public DateTime ValidFrom
00133         {
00134             get { return this.validFrom; }
00135             set { this.validFrom = value; }
00136         }
00137 
00138         public string ValidFromFormatted
00139         {
00140             get
00141             {
00142                 return this.validFrom.ToString(string.Format("{0} HH:mm"
00143                   , System.Globalization.CultureInfo.CurrentCulture.DateTimeFormat.ShortDatePattern));
00144             }
00145         }
00146 
00147         public string ValidUntilFormatted
00148         {
00149             get
00150             {
00151                 return this.validUntil.ToString(string.Format("{0} HH:mm"
00152                   , System.Globalization.CultureInfo.CurrentCulture.DateTimeFormat.ShortDatePattern));
00153             }
00154         }
00155 
00156         public string LogOperationDateFormatted
00157         {
00158             get
00159             {
00160                 return this.logOperationDate.ToString(string.Format("{0} HH:mm"
00161                   , System.Globalization.CultureInfo.CurrentCulture.DateTimeFormat.ShortDatePattern));
00162             }
00163         }
00164 
00168         public DateTime ValidUntil
00169         {
00170             get { return this.validUntil; }
00171             set { this.validUntil = value; }
00172         }
00176         public string RegionName
00177                 {
00178                         get 
00179             {
00180                 if (this.region == null)
00181                     return "";
00182                 return this.region.Name; 
00183             }
00184                 }
00188                 public string DistrictName
00189                 {
00190                         get 
00191             {
00192                 if (this.district == null)
00193                     return "";
00194                 return this.district.Name; 
00195             }
00196                 }
00200                 public string FacilityName
00201                 {
00202                         get 
00203             {
00204                 if (this.facility == null)
00205                     return "";
00206                 return this.facility.Name; 
00207             }
00208                 }
00212         public string PracticeName
00213         {
00214             get 
00215             {
00216                 if (this.practice == null)
00217                     return "";
00218                 return this.practice.Name; 
00219             }
00220         }
00221         
00222                 #endregion
00223         #region Constructors
00224         public MessageBoxRestriction()
00225         {}
00226         public MessageBoxRestriction(IDataRecord record)
00227         {
00228             this.ID = (int)record["PK Message Box Restriction ID"];
00229             if(!(record["PK Region ID"] is DBNull))
00230                 this.region = new Region(record);
00231             if (!(record["PK District ID"] is DBNull))
00232                 this.district = new District(record);
00233             if (!(record["PK Facility ID"] is DBNull))
00234                 this.facility = new Facility(record);
00235             if (!(record["PK Practice ID"] is DBNull))
00236                 this.practice = new Practice(record);
00237             if (!(record["Valid From"] is DBNull))
00238             {
00239                 this.validFrom = (DateTime)record["Valid From"];
00240             }
00241             if (!(record["Valid Until"] is DBNull))
00242             {
00243                 this.validUntil = (DateTime)record["Valid Until"];
00244             }
00245 
00246             try
00247             {
00248                 if (record["Is Deleted"] != null && !(record["Is Deleted"] is DBNull))
00249                     this.isDeleted = (bool)record["Is Deleted"];
00250             }
00251             catch (Exception)
00252             {
00253                 this.isDeleted = false;
00254             }
00255 
00256             try
00257             {
00258                 if (record["Operation"] != null && !(record["Operation"] is DBNull))
00259                     this.logOperation = (string)record["Operation"];
00260                 else
00261                     this.logOperation = null;
00262             }
00263             catch (Exception)
00264             {
00265                 this.logOperation = null;
00266             }
00267 
00268             try
00269             {
00270                 if (record["Operation Date"] != null && !(record["Operation Date"] is DBNull))
00271                     this.logOperationDate = (DateTime)record["Operation Date"];
00272             }
00273             catch (Exception)
00274             {
00275                 
00276             }
00277 
00278         }
00279                 #endregion
00280         #region Overridables
00281         public override string ToString()
00282         {
00283             return this.Region.Name + " " + this.District.Name + " " + this.Facility.Name + " " + 
00284                 this.practice.Name + " " + this.validFrom.ToShortDateString() + " " + this.validUntil.ToShortDateString();
00285         }
00286         #endregion
00287     }
00288 }